import Vue from 'vue';
import App from './App';

Vue.config.productionTip = false

// 常规全局导入
// import BaseButton from './components/BaseButton';
// import BaseIcon from './components/BaseIcon';
// import BaseInput from './components/BaseInput';
// Vue.component('base-button', BaseButton);
// Vue.component('base-icon', BaseIcon);
// Vue.component('base-input', BaseInput);

// 使用 require.context 的方式
import upperFirst from 'lodash/upperFirst';
import camelCase from 'lodash/camelCase';

const requireComponent = require.context(
    './components',
    false,
    /Base[A-Z]\w+.(vue|js)$/
);

requireComponent.keys().forEach(fileName => {
    const componentConfig = requireComponent(fileName);
    const componentName = upperFirst(camelCase(fileName.split('/').pop().replace(/\.\w+$/,'')));
    Vue.component(componentName, componentConfig.default || componentConfig);
});

new Vue({
    render: h => h(App),
}).$mount('#app')